// 查询表单接口
export interface QueryForm {
  pageNo: number
  pageSize: number
  method: string
  dateRange: string[]
}

// 日志基本信息接口
export interface LogInfo {
  log_id: number
  url: string
  method: string
  ip: string
  browser: string
  os: string
  code: number
  cost_time: number
  create_time: string
}

// 日志详细信息接口
export interface LogDetail extends LogInfo {
  error_msg: any
  request_data: string
  response_data: string
  user_agent: string
  error_message: string | null
  stack_trace: string | null
}

// 日志列表响应接口
export interface LogListResponse {
  list: LogInfo[]
  total: number
}

// 请求方法类型
export type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'

export type TagType = 'success' | 'primary' | 'warning' | 'danger' | 'info'

// 请求方法标签类型映射
export const methodTagMap: Record<RequestMethod, TagType> = {
  GET: 'success',
  POST: 'primary',
  PUT: 'warning',
  DELETE: 'danger'
}

// 日期快捷选项接口
export interface DateShortcut {
  text: string
  value: () => [Date, Date]
}

// 日期快捷选项列表
export const dateShortcuts: DateShortcut[] = [
  {
    text: '最近一周',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      return [
        new Date(start.setHours(0, 0, 0)),
        new Date(end.setHours(23, 59, 59))
      ]
    }
  },
  {
    text: '最近一个月',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      return [
        new Date(start.setHours(0, 0, 0)),
        new Date(end.setHours(23, 59, 59))
      ]
    }
  },
  {
    text: '最近三个月',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      return [
        new Date(start.setHours(0, 0, 0)),
        new Date(end.setHours(23, 59, 59))
      ]
    }
  }
]

// 描述项配置接口
export interface DescriptionItem {
  label: string
  prop: string
  type?: 'tag' | 'pre' | 'default'
  tagType?: (value: any) => 'success' | 'warning' | 'primary' | 'danger' | 'info'
  format?: (value: any) => string
  getValue?: (log: LogDetail) => string
  show?: (log: LogDetail) => boolean
}

// 扩展信息接口
export interface ExtendInfo {
  module: string
  controller: string
  action: string
  [key: string]: any
}

// 扩展日志详情接口
export interface LogDetailExtended extends LogDetail {
  params?: string
  request_header?: string
  response_header?: string
  result?: string
  extend?: ExtendInfo
  [key: string]: any
} 